package com.llb666.e.shop.infrastructure.persistence;

import com.llb666.e.shop.domain.entity.ItemsParam;
import com.llb666.e.shop.domain.repository.ItemsParamRepository;
import com.llb666.e.shop.infrastructure.convert.ItemsParamCvt;
import com.llb666.e.shop.infrastructure.mapper.ItemsParamMapper;
import com.llb666.e.shop.infrastructure.po.ItemsParamPo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

/**
 * @author llb666
 * @date 2022/9/12 23:11
 */
@Repository
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class ItemsParamRepositoryImpl implements ItemsParamRepository {

    private final ItemsParamMapper itemsParamMapper;

    /**
     * 查询商品参数.
     * @param itemId 商品Id
     * @return 商品参数
     */
    @Override
    public ItemsParam queryItemsParamById(String itemId) {
        Example example = new Example(ItemsParamPo.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("itemId",itemId);
        return ItemsParamCvt.INSTANCE.po2do(itemsParamMapper.selectOneByExample(example));
    }
}
